import request from '@/config/axios'



// 学校 VO
export interface SchoolVO {
  id: number // 编号
  schoolName: string // 学校名称
  address: string // 详细地址
  description: string // 学校介绍
  enable: boolean // 激活？
  webSite: string // 学校网站
  logo: string // LOGO
  regionId: number // 地域编号
}
export interface SchoolReginVo{
  id:number
  name:string
  parentId:number
  level:number
}
export interface SchoolForSelectVO {
  id: number // 编号
  schoolName: string // 学校名称

}


// 学校 API
export const SchoolApi = {
  // 查询学校分页
  getSchoolPage: async (params: any) => {
    return await request.get({ url: `/td/school/page`, params })
  },

  // 查询学校详情
  getSchool: async (id: number) => {
    return await request.get({ url: `/td/school/get?id=` + id })
  },

  // 新增学校
  createSchool: async (data: SchoolVO) => {
    return await request.post({ url: `/td/school/create`, data })
  },

  // 修改学校
  updateSchool: async (data: SchoolVO) => {
    return await request.put({ url: `/td/school/update`, data })
  },

  // 删除学校
  deleteSchool: async (id: number) => {
    return await request.delete({ url: `/td/school/delete?id=` + id })
  },

  // 导出学校 Excel
  exportSchool: async (params) => {
    return await request.download({ url: `/td/school/export-excel`, params })
  },
  // 获得地域信息，填充到下拉列表
  getReginByParentId: async (parentId:number) =>  {
     return await request.get({url:`/td/region/getReginByParentId?parentId=`+parentId})
  },
  getSchoolsForSelect: async ()=>{

    return await request.get({url:`/td/school/getSchoolsForSelect`})
  },
  getSchoolsByRegionId: async (regionId:number)=>{

    return await request.get({url:`/td/school/getSchoolsForSelect?regionId=`+regionId})
  }


}
